perm filename POOP[206,JMC] blob sn#005324 filedate 1971-01-05 generic text, type T, neo UTF8
00100	                     COMPUTER SCIENCE DEPARTMENT
00200	                         STANFORD UNIVERSITY
00300	
00400	
00500	CS 206           COMPUTING WITH SYMBOLIC EXPRESSIONS        FALL 1970
00600	
00700	
00800	        INSTRUCTIONS FOR PREPARING AND RUNNING RLISP PROGRAMS

00900	
01000		In the first part of this course the exercises to be  run  on
01100	the  machine  are  to  be  written in the RLISP language.  This is an
01200	input language for LISP close to the notation used in class.  We will
01300	use it because the notation is more convenient than the internal LISP
01400	language described in the LISP 1.6 Manual which  we  shall  be  using
01500	later.
01600	
01700		The  RLISP  primer  describes  how  to  use RLISP for someone
01800	already familiar with LISP and with the Stanford time-sharing  system
01900	for the PDP-10.  The familiarity with LISP is to be obtained from the
02000	lectures and the course notes, and this memo is intended to tell  you
02100	enough about the time-sharing system to use RLISP.
02200	
02300		The   first   thing  it  is  necessary  to  understand  about
02400	time-sharing systems is that at different times you will  be  talking
02500	to  different  programs, and the rules for interpreting what you type
02600	depends on what program you are talking  to.   In  order  to  do  the
02700	exercises  you  will  have  to  talk  to  three different programs at
02800	different times, namely: the time sharing system, the SOS text editor
02900	which is used to prepare RLISP programs, and RLISP itself.  Later you
03000	may  find  yourself  talking  to  RLISP  programs  you  have  written
03100	yourself.
03200	
03300	1. The time sharing system.
03400	
03500		The  time  sharing system is quite complex, but we shall need
03600	to know only a few of its commands and other properties.
03700	
03800		1.1. To ensure you are talking  to  the  time-sharing  system
03900	type  <control  C>.  This is accomplished by typing %C% while holding
04000	down the key marked "CTRL".  (This key is like a shift  key  in  that
04100	pressing  it  does not transmit information to the computer.  It only
04200	modifies the information transmitted by pressing other keys if it  is
04300	held  down).   We  shall  abbreviate this ↑C because this is what the
04400	computer types back when you type <control C>.
04500	
04600		No matter what program you are talking  to  initially,  after
04700	↑C, you will be talking to the time sharing system. Always begin your
04800	session by turning on the teletype and typing ↑C.
04900	
05000		1.2. Each command to the system is  terminated  by  <carriage
05100	return>,  abbreviated  <cr>.    Until  <cr> is typed, the line can be
05200	cancelled by typing  <control  U>,  abbreviated  ↑U,  and  individual
05300	characters  can be erased by typing <rubout>.  Several characters can
05400	be erased by several <rubout>s.
05500	
05600		1.3. Another important special character is <ALT MODE>.  Like
05700	<cr>,  this character causes the information typed up to that time to
05800	be transmitted to the program you are talking to, and therefore, that
05900	information  cannot  be taken back by ↑U or <rubout>. When <ALT MODE>
06000	is typed, $ is printed, but  the  effect  of  <ALT  MODE>  cannot  be
06100	achieved  by  typing  $.  The uses of <ALT MODE> will be described in
06200	the sections on SOS and RLISP, both  of  which  use  it  for  certain
06300	control functions.
06400	
06500		1.4.  The first step in using the system is to "log in". Type
06600	↑C to be sure you are talking to the system.  The system will respond
06700	with  <cr> and a . to tell you it is ready to be commanded. Then type
06800	L<cr>, and the system will respond with # to tell you that  it  wants
06900	your  <Project,programmer number> combination. Type 206,<The initials
07000	assigned you><cr>, and the computer will type back ↑C<cr> and another
07100	.  to  show  it  is ready for your next command.  If it types ARE YOU
07200	SURE?, this means you have typed a wrong <Project,programmer number>,
07300	and you can continue by typing the correct one.
07400	
07500	
07600		1.5. When you are done using the system you must  "log  out".
07700	The command for this is K<cr>, and the system will respond with KJOB.
07800	Turn the teletype off to increase its life, which  otherwise  may  be
07900	less  than a quarter.  Be sure and logout, since the system will keep
08000	track of the time you use.
08100	
08200		1.6. There are  two  system  commands  for  calling  the  SOS
08300	editor.   The  first is CREATE <file name><cr> which is used when you
08400	want to create a new RLISP program.  The  system  will  turn  control
08500	over  to  SOS  which will type back 100, meaning to say that it is in
08600	text mode and it is ready for you to type in your program. The second
08700	SOS  calling system command is ED <file name><cr>.  This is used when
08800	the file name in question already exists, and you want to modify  the
08900	file.   SOS  will  type back * to tell you it is ready for a command.
09000	NOTE:  the  commands  to  SOS,  to  be  described  later,   must   be
09100	distinguished  from  the system commands.  The system types . when it
09200	wants a command and SOS types *. RLISP also types *.
09300	
09400		1.7. A very important system command is DEL <file  name><cr>.
09500	This  command  deletes  the  named file.  If you have more than 4K of
09600	files, some of them are subject to random deletion  unless  you  have
09700	special permission to have more.  This limit does not apply while you
09800	are actually on the machine.
09900	
10000		1.8. The system command DIR<cr> will tell you what files  you
10100	have.
10200	
10300		1.9 The system command HELP <name of concept><cr> will type a
10400	short message about how the concept is used.  It is doubtful  whether
10500	these messages will be of much use to you.
10600	
10700		2.0.  The  system  command SEND JMC<cr> can be used to send a
10800	message to the instructor, and SEND GG<cr> can  be  used  to  send  a
10900	message  to  the  teaching assistant.  The SEND command will tell you
11000	what to do next.
11100	
11200	
11300	2. The SOS editor.
11400	
11500		Editor  programs  are used in time-sharing systems instead of
11600	obsolete devices like key punches for preparing  programs  and  data.
11700	They  are  much more convenient than key punches once you get used to
11800	them.
11900	
12000		SOS has very many features described in the SOS  manual,  but
12100	only  a  few of them should be learned at first.  SOS manuals will be
12200	kept in the rooms with the consoles, and later you will have a chance
12300	to buy them if you want.
12400	
12500		Here are the basic features of SOS sufficient for the present
12600	purposes.
12700	
12800		2.1. SOS has three modes of operation -  text  mode,  command
12900	mode,  and  a-mode.  The effects of characters typed are different in
13000	the three cases.  a-mode is associated with the a-command and can  be
13100	skipped for the time being although it is quite useful.
13200	
13300		2.2.  Text mode.  When you are in text mode, characters typed
13400	go into the file being created or edited.  When you enter text  mode,
13500	the  system  will  type  a  line  number, and you can type your text.
13600	Every time you type <cr> the system will give you a new line  number,
13700	and  you  can continue typing.  The <control U> and <rubout> features
13800	work as described above for taking back  partially  typed  lines  and
13900	individual characters.  If you get ahead of the machine's response to
14000	<cr>, no harm will be done.
14100	
14200		To go from text mode to control mode type  <ALT  MODE>.   You
14300	will  lose  any  partially  typed line so be sure and finish the last
14400	used line with <cr>.
14500	
14600		2.3. Control mode.  In this mode there are numerous commands.
14700	Each  of  them  consists  of  a  single character followed by certain
14800	parameters followed by <cr>.
14900	
15000		2.4. The most important  kind  of  parameter  is  the  range.
15100	300:1400  designates  the  range  from line number 300 to line number
15200	1400.  If the range is a single line we can just use the line number,
15300	e.g. 300 if the range is the single line 300. In forming the range, .
15400	denotes the current line, e.g. the  last  line  referred  to,  and  *
15500	denotes the last line of the file.
15600	
15700		2.5. Here are the most important commands.
15800	
15900		2.6. e<cr>.  This command terminates editing, returns control
16000	to the system, and makes the edited file the current file  associated
16100	with  the  <file name> of the CREATE or ED command that initiated the
16200	edit. <control C> will cause a return to the  system,  but  the  edit
16300	will  not  take  effect,  i.e.  the file will be as it was before the
16400	current ED command or non-existent if the edit was initiated  with  a
16500	CREATE command.
16600	
16700		2.7. i<line number>(,<increment>)<cr>.  Here, the parentheses
16800	around ,<increment> indicate that an  increment  is  optional.   This
16900	command  causes SOS to enter text mode right after the indicated line
17000	number and to enter successive lines at the  given  increment.   This
17100	increment  is  initially 100, but is reset if the increment parameter
17200	of an i command is used.  The i command is the main way  of  entering
17300	text  mode.   i*<cr> will enter text mode at the end of the file.  If
17400	you enter the file in the middle for the purpose of inserting  lines,
17500	SOS will interpolate line numbers in an ingenious way.
17600	
17700		2.8.  p<range><cr>  will print the text in that range on your
17800	console.  p/1<cr> will print your whole  file  assuming  you  haven't
17900	read  the  SOS  manual  and  learned  the facts about pages that I am
18000	trying to spare you.
18100	
18200		2.9. d<range><cr> will delete  the  lines  in  the  indicated
18300	range.
18400	
18500		2.10.     s<old     string><ALT     MODE><new     string><ALT
18600	MODE><range><cr> will subsitute <new string> for each  occurrence  of
18700	<old  string>  in  the  given  range, and will print the lines it has
18800	changed.  You can't do this using a key punch.
18900	
19000		2.11. w<cr> will save the state of the edit up to now on  the
19100	file name edited.  This is valuable if the system is in an unreliable
19200	state or if you fear making a catastrophic blunder in  editing  after
19300	investing  considerable effort.  The distinction between prudence and
19400	neuroticism is not always easy to make.
19500	
19600		2.12. n<cr> will renumber your file with increments  of  100,
19700	thus  smoothing  out  any insertions you have made.  You must then be
19800	prepared to  type  out  the  file  using  the  p  command.  Here  the
19900	distinction to be made is between esthetics and neurosis.
20000	
20100		2.13. a<line number><cr> will put you into a-mode editing the
20200	named  line.   This  convenient  command  has  a  confusing  host  of
20300	subcommands, some of which are as follows:
20400	
20500	<space>  moves one space through the line.  The character spaced over
20600	will be printed.  7<space> will space over 7 characters.
20700	
20800	<rubout> will move backwards along the line not erasing.
20900	
21000	c<character> will change the next character to <character>.
21100	
21200	d will delete a character.  7d will delete 7 characters.
21300	
21400	i will enter a sub-mode in which successive characters typed will  be
21500	inserted.   The  i  sub-mode  is  terminated  by  typing  <ALT MODE>.
21600	<rubout> works in the i sub mode.
21700	
21800	<cr> will end the a-mode, type the rest  of  the  characters  in  the
21900	line, and return to control mode.
22000	
22100	s<character>  will  skip  over  characters  to the next occurrence of
22200	<character>.  This is a very useful command.
22300	
22400	k<character> will kill  characters  up  to  the  next  occurrence  of
22500	<character>.
22600	
22700		2.14.  SOS has many more features, but don't bother with them
22800	until you have had some experience with these.
22900	
23000	
23100	3. RLISP
23200	
23300		In  general,  the  RLISP primer is an adequate description of
23400	the workings of RLISP, but I want to emphasize that RLISP can
23500	be used in two ways.
23600	
23700	The simplest way to use RLISP is to type
23800	
23900	R RLISP<cr>
24000	
24100	to the system, and when RLISP types *, type
24200	
24300	(BEGIN)<cr>
24400	
24500	and  then  give  commands to RLISP.  These commands are of two kinds:
24600	defining functions and using them.  Thus, if if we type
24700	
24800	ALT X ← IF NULL X OR NULL CDR X THEN X ELSE CAR X . ALT CDDR X;<cr>
24900	
25000	we will have defined the function %alt% of the lecture  notes,  which
25100	there is written
25200	
25300		alt x ← if nx ∨ n d x then x else a x . alt dd x.
25400	
25500	If we now type
25600	
25700	ALT '(A B C D E F);<cr>
25800	
25900	then RLISP will type back
26000	
26100	(A C E)
26200	
26300	*.
26400	
26500	The  *  indicates RLISP is ready for another command.  You can define
26600	and redefine and use functions to your heart's content, and when  you
26700	are  done,  type  <control  C> to get back to the system and log out.
26800	What could be simpler?
26900	
27000		This way of using RLISP has two disadvantages.   First,  when
27100	you are done, all you have is your teletype paper. Your functions are
27200	not on a file for future reference.  Secondly, the only way  you  can
27300	change  a  function  once it is typed in (except that ↑U and <rubout>
27400	work while entering lines) is to retype it completely.
27500	
27600		The  other  way  of  using  RLISP  is  to  prepare  a file of
27700	functions using SOS, then enter RLISP, and then get your functions in
27800	by  using  the  RLISP  command  IN <file name>;.   You then apply the
27900	functions to examples, and when you find a mistake, type <control  C>
28000	and  then  ED<cr>,  and then re-edit the file with your functions and
28100	start over with a new copy of RLISP.  This way you always have a copy
28200	of your functions and can get back to them the next day.
28300	
28400		A more convenient way of going back and forth  between  RLISP
28500	and SOS will shortly be provided.
28600	
28700		The  example  on  page  22  of  the  RLISP  primer  is  quite
28800	informative about the  first  method  of  operation,  but  needs  the
28900	following amendments.
29000	
29100	Before the beginning put in
29200	
29300	<control C>
29400	
29500	L
29600	
29700	206,BA1
29800	
29900	Change the statement R REDUCE to R RLISP if this has not already been
30000	done in your primer.
30100	
30200	After this, type
30300	
30400	<control C>
30500	
30600	K
30700	
30800	and when the system types KJOB, turn off the teletype.